package com.gzdh.dishrecognition.ui.view;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.dhkj.web.utils.MyObserverRes;
import com.dhkj.web.utils.RequestUtils;
import com.gzdh.dishrecognition.R;

public class WithDialog extends AppCompatActivity {

    private ImageView m_imgInsideCircle;  //内圆
    private ImageView m_imgOuterCircle;   //外圆

    private Animation m_animInsideCircle; //内圆动画
    private Animation m_animOuterCircle;  //外圆动画

    private AnimationDrawable m_frameAnim;

    private Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view_dialog_with);
        rotateAnimInit();

        mContext = this;



    }

    private void checkJiesuan() {
        handler.postDelayed(runnable, 1000);//触发定时器

    }


    private Handler handler = new Handler();
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            //todo what you want
//            handler.postDelayed(runnable, 1000);


        }
    };



    private void rotateAnimInit() {
        m_imgInsideCircle = (ImageView) findViewById(R.id.imgInsideCircle);
        m_imgOuterCircle = (ImageView) findViewById(R.id.imgOuterCircle);

        m_animInsideCircle = AnimationUtils.loadAnimation(this, R.anim.inside_rotate_anim);
        m_animInsideCircle.setInterpolator(new LinearInterpolator()); //匀速动画

        m_animOuterCircle = AnimationUtils.loadAnimation(this, R.anim.outer_rotate_anim);
        m_animOuterCircle.setInterpolator(new LinearInterpolator()); //匀速动画


        //开始动画
        startAnimation();
    }

    //开始动画
    private void startAnimation() {
        m_imgInsideCircle.startAnimation(m_animInsideCircle);
        m_imgOuterCircle.startAnimation(m_animOuterCircle);
//        ImageView imgView = (ImageView) findViewById(R.id.frameAnim);
//        m_frameAnim = (AnimationDrawable) imgView.getBackground();
//        m_frameAnim.start();
    }

    //
    //停止动画
    private void stopAnimation() {
        m_imgInsideCircle.clearAnimation();
        m_imgOuterCircle.clearAnimation();

//        m_frameAnim.stop();
    }
}
